import { BaseEntity } from "./BaseEntity";

export class PmsCategory extends BaseEntity {
    name!: string | null;
    parentId?: number | null;
    parent?: PmsCategory | null;
    rootId!: number | null;
    root?: PmsCategory | null;
    level!: number | null;
    children?: PmsCategory[] = [];

    /**
     * 自定义JSON序列化方法
     * @returns 
     */
    toJSON?() {
        const obj = {
            id: this.id,
            createdTime: this.createdTime,
            lastModifiedTime: this.lastModifiedTime,
            name: this.name,
            parentId: this.parentId,
            rootId: this.rootId,
            level: this.level,
            children: this.children,
        };

        return obj;
    }
}

export default PmsCategory;